package shiyan5;

public class Tongji {
	String s1; 
	String s2;
	Tongji(String s1,String s2){
		this.s1 = s1;
		this.s2 = s2;
	}
	void tongji() {
        int counts = 0;
        while(s1.length() > 0) {
            int num = s1.indexOf(s2);
            if(num != -1) {
                counts+=1;
                s1 = s1.substring(num+s2.length(),s1.length());   
            }else {
            	break;
            }
        }
        System.out.println(s2 + "出现了" + counts + "次");
    }
}

